package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.dto.SetmealDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    @AutoFill(value = OperationType.INSERT)
    void add(Dish dish);

    Dish selectById(Integer id);

    Integer countByCategory(Long id);

    List<DishVO> selectListByDishId(Long categoryId);

    List<Dish> selectListById(Long categoryId);


    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);


    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    void delete(Long id);

    Dish getById(Long id);

    /**
     * 菜品修改
     */
    @AutoFill(value = OperationType.UPDATE)
    void updateDish(Dish dish);

    @Select("select a.* from dish a left join setmeal_dish b on a.id = b.dish_id where b.setmeal_id = #{setmealId}")
    List<Dish> getByIds(Long id);


}
